package com.dx.VegetableOxygenBarBackEnd.common;

/**
 * 返回工具类
 *
 * @author dengxiao
 */
public class ResultUtils {
    /**
     * 成功
     * @param data
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<T>(0, data, "success","");
    }

    /**
     * 失败
     * @param errorCode
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> error(ErrorCode errorCode) {
        return new BaseResponse<T>(errorCode.getCode(), null, errorCode.getMessage(),errorCode.getDescription());
    }
    public static <T> BaseResponse<T> error(ErrorCode errorCode,String message , String decription) {
        return new BaseResponse<T>(errorCode.getCode(), null, message,decription);
    }
    public static <T> BaseResponse<T> error(ErrorCode errorCode,String message ) {
        return new BaseResponse<T>(errorCode.getCode(), null, message,errorCode.getDescription());
    }
    public static <T> BaseResponse<T> error(int code,String message ,String decription) {
        return new BaseResponse<T>(code, null, message,decription);
    }
}
